set(extra_share_compile_flags "")
set(extra_static_compile_flags "")
#NOTE -MP flag Disable unnecessary warning for vc
# if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
#     set(CMAKE_CXX_FLAGS "/bigobj")
#     set(extra_share_compile_flags "-MP /wd4251")
#     set(extra_static_compile_flags "-MP")
#     set(disabled_compile_warnings "/wo4530 /wo4251 /wo4838")
# endif()
#ts parser test configuration
set(CURRENT_PROJECT_FILES
abstract_parser.hpp
ast_to_json.cpp
ast_to_json.hpp
ast_visitor.hpp
bail_error_strategy.cpp
bail_error_strategy.h
cyclone_lexer_base.cpp
cyclone_lexer_base.h
cyclone_parser_base.cpp
cyclone_parser_base.h
cyclone_parser_support.h
dummy_node.cpp
dummy_node.h
estree.cpp
estree.hpp
estree_visitor.cpp
estree_visitor.hpp
cyclone_type_visitor.h
cyclone_type_visitor.cpp
json.hpp
json_visitor_helper.cpp
json_visitor_helper.hpp
macros.h
syntax_error.cpp
syntax_error.h
syntax_error_formatter.hpp
syntax_error_list.h
utils.cpp
utils.h
wasm_wrapper.cpp
wasm_wrapper.h
)
file(GLOB_RECURSE TS_PARSER_GEN cpp-gen/*.cpp)
file(GLOB_RECURSE PARSER_LIB_SRC
    ${TS_PARSER_GEN}
    ${CURRENT_PROJECT_FILES}
)
# This library is compiled as a DYNAMIC library by default, unless
# Create static or shared library target.
if (PARSER_LIBRARY_STATIC)
# Static
add_library(cyclone_parser STATIC ${PARSER_LIB_SRC})
target_link_libraries( cyclone_parser  
                        antlr4_static)
#NOTE , for static build need to store the symbols as pulic
#NOTE Define PARSER_LIBRARY_STATIC when building and using this library 
#NOTE Add ANTLR4CPP_EXPORTS so as not to import(dllimport) symbols in ANTLR 
target_compile_definitions(cyclone_parser
PUBLIC
        PARSER_LIBRARY_STATIC
        ANTLR4CPP_EXPORTS )

set_target_properties( cyclone_parser
                        PROPERTIES
                        COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
else()
# Dynamic
add_library(cyclone_parser SHARED ${PARSER_LIB_SRC})
target_link_libraries( cyclone_parser  
                        antlr4_shared)
# Make all non-exported symbols are hidden by default (similar to Windows)
# Treat the exported symbols as exported (and not imported) when building the library
target_compile_definitions(cyclone_parser
PRIVATE
    PARSER_LIBRARY_BUILD
    ANTLR4CPP_EXPORTS
)
set_target_properties(cyclone_parser
    PROPERTIES
        C_VISIBILITY_PRESET hidden
        CXX_VISIBILITY_PRESET hidden
        COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
endif()


# Export the library's public include path to dependent targets
target_include_directories(cyclone_parser
INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}
)

add_subdirectory(test)


